package com.example.weektwo.dailysupplies.one;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.weektwo.R;

import java.util.List;

public class DailyShopAdapter extends BaseAdapter {
    private static final String TAG = "er";
    Context context;
    List<String> kindList;
    String kindName;
    public DailyShopAdapter(Context context, List<String> kindList) {
        this.context = context;
        this.kindList = kindList;
    }

    @Override
    public int getCount() {
        return kindList.size();
    }

    @Override
    public Object getItem(int position) {
        return kindList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView==null) {
            convertView= LayoutInflater.from(context).inflate(R.layout.item_daily_list,null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }{
            holder= (ViewHolder) convertView.getTag();
        }

        kindName = kindList.get(position);
        Log.d(TAG, "kindName: "+kindName);
        holder.tv.setText(kindName);
        return convertView;
    }
    class ViewHolder{
        TextView tv;
        ImageView iv;
        public ViewHolder(View view){
            tv=view.findViewById(R.id.item_daily_tv);
            iv=view.findViewById(R.id.item_daily_iv);


        }
    }
}
